package com.nt.mes_leader.base_activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;

/**
 * Created by netuo020 on 2017/9/18.
 */

public abstract class BaseActivity extends Activity {

    protected abstract <T> void actionStart(Activity activity, Class<T> cls);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
    }

    @Override
    protected void onResume() {
        super.onResume();
        initView();
        initData();
    }

    /**
     * 初始化界面
     */
    protected abstract void initView();

    /**
     * 初始化数据
     */
    protected abstract void initData();

    /**
     * 是否有值
     * @param extra
     * @return
     */
    protected boolean hasExtra(String extra){
        return this.getIntent().hasExtra(extra);
    }

    @SuppressWarnings("unchecked")
    protected <T> T getParam(String key){
        Intent intent = this.getIntent();
        Object obj = intent.getExtras().get(key);
        if(obj == null){
            return null;
        }
        return (T)obj;
    }
}
